package com.javatest;

/**
 * @author LL
 * 使用循环输出斐波那契数列的前10个数
 * @create 2020-12-10 17:45
 */
public class Subject16 {

    public static long fibLoop(int num) {
        if(num < 1 || num > 92)
            return 0;
        long a = 1;
        long b = 1;
        long temp;
        for(int i = 3; i <= num; i++) {
            temp = a;
            a = b;
            b += temp;
        }
        return b;
    }

    public static int fun(int i) {
        if (i == 0) {
            return 0;
        }else if (i == 1 || i == 2){
            return 1;
        }else{
            return fun(i -1) + fun(i - 2);
        }
    }

    public static void main(String[] args) {
//        long l = fibLoop(50);
//        System.out.println(l);
        for (int i = 0; i < 20; i++) {
            int fun = fun(i);
            System.out.println(fun);
        }
    }
}
